Skip to content

Query history: Add new VariantAnalysisHistoryItem type#1590

Merged
shati-patel merged 7 commits intomainfrom
shati-patel/variant-analysis-history-item
Oct 14, 2022
Merged

Query history: Add new VariantAnalysisHistoryItem type#1590
shati-patel merged 7 commits intomainfrom
shati-patel/variant-analysis-history-item

Conversation

@shati-patel
Copy link
Copy Markdown
Contributor

@shati-patel shati-patel commented Oct 12, 2022

Adds a new VariantAnalysisHistoryItem type to QueryHistoryInfo, so that the query history view will be able to display variant analysis items in future.

This PR adds the type itself and some placeholder "TODO"s to get the query history code to type check. Actually implementing the methods is tracked in a follow-up issue.

See internal linked issue for details!

Checklist

N/A - internal only 🦞

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@shati-patel shati-patel marked this pull request as ready for review October 12, 2022 16:13
@shati-patel shati-patel requested review from a team as code owners October 12, 2022 16:13
Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented on a few locations where we should be handling an unexpected type. Also, we should probably be bumping the serialization version number.

case 'remote':
queryPath = finalSingleItem.remoteQuery.queryFilePath;
break;
case 'variant-analysis':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably add a default case.

} else {
} else if (item.t === 'remote') {
await this.removeRemoteQuery(item);
} else if (item.t === 'variant-analysis') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an else block to handle unknown types.

return item.remoteQuery.queryText;
case 'variant-analysis':
return 'TODO';
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default case.

// queries aged out.
return asyncFilter(parsedQueries, async (q) => {
if (q.t === 'remote') {
if (q.t === 'remote' || q.t === 'variant-analysis') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On line 18, there is a version property that gets added. We probably want to bump this to version 2. This would mean that in the rare case someone downgrades from a version of the extension with the variant-analysis type to one without, they won't have errors when loading query history (it will mean that they lose their query history, but I think that is a reasonable tradeoff).

@shati-patel shati-patel force-pushed the shati-patel/variant-analysis-history-item branch from 5971292 to 127a23e Compare October 13, 2022 10:49
@shati-patel
Copy link
Copy Markdown
Contributor Author

Thanks for the review, @aeisenberg! Addressed your comments 🤩

And thank you for pointing out the query serialization versions—I didn't know about those 👀 Would you mind double-checking that the version bump looks okay? 🙇🏽‍♀️ (see 127a23e)

Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks good. A few more things I noticed.

const data = await fs.readFile(fsPath, 'utf8');
const obj = JSON.parse(data);
if (obj.version !== 1) {
if (obj.version !== 1 && obj.version !== 2) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine. In the future we could change it to [1, 2].includes(obj. version). This will make it easier to extend.

const obj = JSON.parse(data);
if (obj.version !== 1) {
if (obj.version !== 1 && obj.version !== 2) {
void showAndLogErrorMessage(`Unsupported query history format: v${obj.version}. `);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this message now, and it won't make much sense to users. Perhaps we can change it? Maybe something like this:

Suggested change
void showAndLogErrorMessage(`Unsupported query history format: v${obj.version}. `);
void showAndLogErrorMessage(`Can't parse query history. Unsupported query history format v${obj.version}.`);

const filteredQueries = queries.filter(q => q.t === 'local' ? q.completedQuery !== undefined : true);
const data = JSON.stringify({
version: 1,
version: 2,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here documenting what has changed between v1 and v2?

@shati-patel shati-patel merged commit 8b2a3b1 into main Oct 14, 2022
@shati-patel shati-patel deleted the shati-patel/variant-analysis-history-item branch October 14, 2022 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants